//
//  DiscoverButtonTableViewCell.m
//  Coco_Music
//
//  Created by 强哥 on 15/6/22.
//  Copyright (c) 2015年 寇广超. All rights reserved.
//

#import "DiscoverButtonTableViewCell.h"
#import "UIImageView+WebCache.h"


@implementation DiscoverButtonTableViewCell



-(void)setArray1:(NSMutableArray *)array1
{
    if (_array1 != array1) {
        [_array1 release];
        _array1 = [array1 retain];
    }
    for (int i = 0; i<array1.count; i++) {
        self.button = [BaseButton buttonWithType:UIButtonTypeCustom];
        self.button.tag = 10000+i;
        self.button.frame = CGRectMake(10+([UIScreen mainScreen].bounds.size.width-40)/3*i + i * 10, self.frame.origin.y+10, ([UIScreen mainScreen].bounds.size.width-40)/3, ([UIScreen mainScreen].bounds.size.width-40)/3);
        [self.button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        
        self.button.Section = _Section;
        self.TitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10+([UIScreen mainScreen].bounds.size.width/3)*i, _button.frame.size.height+12, 100, 40)];
        self.TitleLabel.numberOfLines = 0;
        self.TitleLabel.font = [UIFont systemFontOfSize:15];
        
        self.TitleImage = [[UIImageView alloc]init];
        self.TitleImage.frame = CGRectMake(0, 0, ([UIScreen mainScreen].bounds.size.width-45)/3, ([UIScreen mainScreen].bounds.size.width-45)/3);
        Discover *dis = [_array1 objectAtIndex:i];
        self.TitleLabel.text = dis.CollectionName;
        self.button.urlId = dis.CollectionId;
        self.TitleImage.layer.masksToBounds = YES;
        self.TitleImage.layer.cornerRadius = 10;
        [self.TitleLabel sizeToFit];
        NSURL *url = [NSURL URLWithString:dis.CollectionPic_url];
        [self.TitleImage sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"cm2_default_artist_banner-1"]];
        
        [self.button addSubview:self.TitleImage];
        [self.contentView addSubview:_TitleLabel];
        [self.contentView addSubview:_button];
        [self.TitleLabel release];
        [self.TitleImage release];
        self.backgroundColor = [UIColor clearColor];
    
    }
}

-(void)buttonAction:(BaseButton *)button
{
    [self.Mypushi pushDiscoverButton:button.urlId];
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
